home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1367 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.2 KB  |  61 lines

  1. Newsgroups: comp.lang.c
  2. Path: gail.ripco.com!mambuhl
  3. From: mambuhl@ripco.com (Martin Ambuhl)
  4. Subject: Re: stricmp()            
  5. X-Nntp-Posting-Host: foley.ripco.com
  6. Message-ID: <DL3u99.9wH@rci.ripco.com>
  7. Sender: usenet@rci.ripco.com (Net News Admin)
  8. Organization: Ripco Internet BBS Chicago
  9. Date: Sat, 13 Jan 1996 05:36:45 GMT
  10. X-Ident-Sender: mambuhl
  11.  
  12. jackal@gcomm.com (Jack Alvrus)
  13. in <8213293982604@demosys.gcomm.com> wrote:
  14.  
  15. >stricmp() is an ANSI library function, right?...
  16.  
  17. Wrong.
  18.  
  19. >...  So it should exhibit, if
  20. >not consistent, at least *documented* behavior, right?
  21.  
  22. The premise is false, but the conclusion is none the less true.  The
  23. behavior should be documented:
  24.  
  25. ISO clause 4:
  26.     "An implementation shall be accompanied by a document that defines
  27.     all implementation defined characteristics and all extensions."
  28.  
  29.  
  30. >So, is stricmp("a","^") always less than zero or greater than zero, and
  31. >if neither, is there any documented behavior in this case?
  32.  
  33. >I ask because '^' is *between* 'A' and 'a' in ASCII.  So if stricmp()
  34. >always compares to upper case letters, stricmp("a","^") is always less
  35. >than zero.  If it always compares to lower case letters,
  36. >stricmp("a","^") is always *greater* than zero.
  37.  
  38. >My compiler's reference manual does not say one way or another, but a
  39. >quick test showed stricmp("a","^") < 0.
  40.  
  41. >Any comments?
  42.  
  43. Your implementation should have defined what a "case-insensitive"
  44. comparison is.  Failing that, it has not met the requirement of ISO
  45. clause 4.  In the absence of such documentation, I would assume for
  46. historical reasons* that the mapping was to upper case, but that
  47. assumption could be wrong.
  48.  
  49.  * [For ASCII representations]
  50.   ASCII derives from the TTY codes. Many TTY devices had only upper
  51.  case, so I would expect a mapping _when_ it occurred would be for ASCII
  52.  to the 040-0137 (' ' through '_') range, and specifically the 0101-0132
  53.  range ('A' through 'Z') for case-insensitivity of alpha chars.  Notice
  54.  that the printing representation of a control character x in the 0-037
  55.  range is traditionally '^' followed by (x|0100) which is the 0100-0137
  56.  range.
  57.                                    
  58. --
  59. * Martin Ambuhl       net: mambuhl@ripco.com
  60. * Chicago, IL (USA)    
  61.